<%-- 
    Document   : listOfOrders
    Created on : Apr 19, 2013, 18:34:59 AM
    Author     : Alexandra
--%>
<%@page import="com.charlie.beans.ShipmentOrder"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>

<%@include file="/header.jsp" %>

<div class="left_side"> 
    <jsp:include page="/blocks/conditionalLeftBar.jsp" />  
</div>

<div class="right_side">
    <h2 class="content_title">View orders</h2>
    <div class="white_block">
        <%
            List<ShipmentOrder> orders_list = (List<ShipmentOrder>) request.getAttribute("orderList");
            if (orders_list != null) {
                SimpleDateFormat format = new SimpleDateFormat("MMM dd,yyyy");

        %>
        <h2 style="text-align: center;"> Select the order you want to deliver </h2>
        <table class="typycal_table">
            <thead>
                <tr class="underLinedRow"> 
                    <th> id </th>
                    <th> creation date</th>
                    <th> user e-mail</th>
                    <th> location </th>
                </tr>
            </thead>
            <tbody>
                <%
                    for (ShipmentOrder item : orders_list) {%>
                <tr>
                    <td>
                        <%=item.getSoId()%>
                    </td>
                    <td>
                        <%=format.format(item.getCreationDate())%>
                    </td>
                    <td>
                        <% if (item.getEmail() != null) {
                                out.println(item.getEmail());
                            } else {
                                out.println(" no info ");
                            }
                        %>
                    </td>
                    <td>
                        <%=item.getLocation()%>
                    </td> 
                    <td>
                        <form method="GET" action="${pageContext.request.contextPath}/courier/order"/>
                            <input name="idOfOrder" type="hidden" value="<%=item.getSoId()%>">
                            <input class="btn" value="Deliver" type="submit" > 
                        </form>
                    </td>
                </tr>
                <%
                    }
                } else {
                    out.print("<h1>No orders</h1>");
                }
                %>
            </tbody>
        </table>
    </div>  <jsp:include page="/blocks/pages.jsp">
        <jsp:param name="path" value="courier/orders" />
    </jsp:include>

</div>

<%@include file="/footer.jsp" %>